DataHandler.AccountsWithSessions
A more robust account system with token verification, session checks, expiries, etc.
markdown
Represents a user’s active session record.
Properties:
Constructors:
ActiveSession() { }
ActiveSession(string username,
string sessionID,
string sessionKey,
string expiry,
string isTrusted,
string checksAndLastTry)
Encapsulates the decrypted session details returned to the caller.
Properties (all SecureData):
Constructors:
ConnectedSessionReturn() { }
ConnectedSessionReturn(string username,
string sessionKey,
string sessionID,
SecureData directory)
Holds both the initial session info and recovery key when creating a new user.
Properties:
Constructors:
ReturnCreateUser() { }
ReturnCreateUser(ConnectedSessionReturn sessionReturn,
SecureData recoveryKey)
Global configuration for session lifetimes and recovery policies.
Properties (static):
Methods (static):
Same as in Accounts, stores per-user credentials and encryption keys.
Properties:
Constructors:
AccountData() { }
AccountData(string username,
PasswordCheckData password,
string dataEncryptionKey,
string recoveryDataKey)
Initializes Users.json with empty AccountsList and empty Sessions arrays.
Parameters:
Returns: Task
Registers a new user and returns a recovery key.
Steps:
Returns: Task — The recovery key.
Exceptions: If username already exists.
Authenticates credentials and creates a new session.
Parameters:
Process:
Returns: Task<(SecureData dataKey, ConnectedSessionReturn sessionInfo)>
Exceptions: On invalid credentials or I/O errors.
Checks session validity, expiry, and integrity; extends expiry if valid.
Parameters:
Process:
Exceptions: On tampering or parsing errors.
Invalidates a session immediately.
Process: Calls ValidateSession (throws if invalid), then removes the session record and saves JSON.
Returns: Task
Deletes a user account and all its sessions.
Process:
Returns: Task
Allows password reset from within an active session, enforcing recovery-policy limits.
Process:
Returns: Task
Exceptions: On recovery key failures or policy triggers.
Returns the list of all registered usernames.
Parameters:
Returns: Task<List>